package pattern20;

/**
 * p254
 * 责任链模式
 *
 * @author wdl
 */
public class ChainOfResponsibilityPattern {
    public static void main(String[] args) {
        BaseHandler handler1 = new ConcreteHandler1();
        BaseHandler handler2 = new ConcreteHandler2();
        BaseHandler handler3 = new ConcreteHandler3();

        handler1.setSuccessor(handler2);
        handler2.setSuccessor(handler3);

        int[] requests = {2, 5, 14, 22, 28, 3, 7, 27, 20};

        for (int request :
                requests) {
            handler1.handleRequest(request);
        }
    }
}
